package com.hu.controller;


import com.hu.pojo.Result;
import com.hu.utils.AliOSSUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;
import java.util.UUID;

@Slf4j
@RestController
public class UploadController {

    @Autowired
    private AliOSSUtils aliOSSUtils;

    //文件上传--阿里云OSS
    @PostMapping("/upload")
    public Result upload(MultipartFile image) throws IOException {
        log.info("文件上传,文件原始名:{}",image.getOriginalFilename());

        //调用阿里云OSS工具类
        String url = aliOSSUtils.upload(image);
        log.info("文件上传成功的url:{}",url);

        return Result.success(url);

    }
}
